<template>
  <!-- 下钻页面 -->
  <div class="indexItem">
    <!-- 顶部 -->
    <div class="header-box">
      <div class="back" @click="back">
        <i class="el-icon-back"></i><span>返回BI页</span>
      </div>
      <div class="item">
        <div :class="active == item.value ? 'active' : ''" @click="changeItem(item.value)" v-for="item in itemArr"
          :key="item.value">
          {{ item.label }}
        </div>
      </div>
      <div class="time"></div>
    </div>
    <div class="category">
      <div v-for="(item, index) in categoryArr" :key="index" :class="category == index ? 'active' : ''"
        @click="changeCategory(index)">{{ item }}</div>
    </div>
    <div class="main-box bg">
      <companyEquipment v-if="category == 0"></companyEquipment>
      <projectEquipment v-if="category == 1 || category == 2"></projectEquipment>
    </div>
  </div>
</template>
<script>
import companyEquipment from "./components/companyEquipment.vue"
import projectEquipment from "./components/projectEquipment.vue"

export default {
  components: {
    companyEquipment, projectEquipment
  },
  data() {
    return {
      itemArr: [
        { label: "设备", value: 1 },
        { label: "设备配件", value: 2 },
        { label: "垃圾处置", value: 3 },
        { label: "客用品", value: 4 },
        { label: "化学品", value: 5 },
        { label: "工具", value: 6 },
        { label: "劳保", value: 8 },
        { label: "其他", value: 9 },
      ],
      categoryArr: ['公司', '项目', '个人'],
      active: 1,
      category: 0
    }
  },
  created() {
    this.active = this.$route.query.active
    this.category = this.$route.query.type
  },
  methods: {
    // 类别
    changeCategory(idx) {
      this.category = idx
    },
    // 点击项目
    changeItem(val) {
      this.active = val;
    },
    // 返回上一页
    back() {
      this.$router.push({ path: "/report/materialsBI" });
    },
  }
}
</script>
<style lang="scss" scoped>
.indexItem {
  width: 100vw;
  min-height: 100vh;
  background-color: #dee0ed;
  position: relative;
  display: flex;
  flex-direction: column;

  .header-box {
    height: 6vh;
    display: flex;
    justify-content: space-between;
    padding: 0 32px;
    background: #ffffff;

    >div {
      height: 100%;
      width: 15%;
      color: #666666;
      font-size: 16px;
      line-height: 6vh;
    }

    .back {
      cursor: pointer;
      color: #333;
    }

    .item {
      width: 70%;
      display: flex;
      margin: 0 auto;
      justify-content: center;
      font-weight: 400;
      font-size: 16px;
      color: #666666;

      div {
        padding: 0 32px;
        line-height: 6vh;
        cursor: pointer;
        overflow: hidden;
      }

      .active {
        background: linear-gradient(180deg,
            rgba(0, 79, 250, 0.2) 0%,
            rgba(0, 79, 250, 0) 100%);
        border-top: #004ffa 4px solid;
        font-weight: bold;
        color: #333;
        line-height: 5vh;
        position: relative;
      }


    }

    .time {
      text-align: right;
    }
  }

  .bg {
    background-image: url('~@/assets/images/bgBI.png');
    background-size: 100% 100%;
  }

  .category {
    display: flex;
    font-size: 14px;
    color: #333333;

    margin-top: 1vh;
    justify-content: center;

    div {
      padding: 0 80px;
      background: #FFF;
      height: 3vh;
      line-height: 3vh;
      cursor: pointer;
    }

    div:nth-child(1) {
      border-radius: 8px 0 0 0;
    }

    div:nth-child(2) {
      border-left: 1px solid #EEEEEE;
      border-right: 1px solid #EEEEEE;
    }

    div:nth-child(3) {
      border-radius: 0 8px 0 0;
    }

    .active {
      color: #fff;
      background: #004FFA;
    }
  }

  .main-box {
    height: 90vh;
    padding: 0 32px 30px;

  }

}
</style>